<?php
require_once(MODX_BASE_PATH . 'assets/snippets/gCart/config.php');
require_once(MODX_BASE_PATH . 'assets/snippets/gCart/classes/ups.php');
require_once(MODX_BASE_PATH . 'assets/snippets/gCart/include/gDiscount.php');
require_once(MODX_BASE_PATH . 'assets/snippets/gCart/include/gCart.inc.php');

$gParams  = array();
$gParams['gItemTpl'] = $modx->getChunk($gItemTpl);
$gParams['gCartTpl'] = $modx->getChunk($gCartTpl);
$gParams['gAjaxTpl'] = $modx->getChunk($gAjaxTpl);
$gParams['gEmptyTpl'] = $modx->getChunk($gEmptyTpl);

if(!$gID) $gID = '775498075155100';
if(!$gKey) $gKey = 'aUxxZT8A_NtOiiaP0U1-Og';
if(!$gTaxRate) $gTaxRate = '0.065';
if(!$gTaxShipping) $gTaxShipping = 'true';
if(!$gZipCode) $gZipCode = '62902';
if(!$gCity) $gCity = 'Carbondale';
if(!$gState) $gState = 'IL';
if(!$gShipID) $gShipID = 'Blue Sky';

$gParams['gID'] = $gID;
$gParams['gKey'] = $gKey;
$gParams['gTaxRate'] = $gTaxRate;
$gParams['gTaxShipping'] = $gTaxShipping;
$gParams['gZipCode'] = $gZipCode;
$gParams['gCity'] = $gCity;
$gParams['gState'] = $gState;
$gParams['gShipID'] = $gShipID;


$gCart = processgCart($gParams);
$finalOutput = getOutput($gParams, $gCart);

//Google checkout only supports a shipment of less than 150lbs.
if($gCart && $_SESSION["gCartInfo"]['weight'] <= 150) 
	$finalOutput = str_replace('[+gButton+]',getButton($gCart,'SMALL'),$finalOutput);
	else
	$finalOutput = str_replace('[+gButton+]','<p>Your cart is too heavy.  Try removing one item and <a href="' . $modx->makeURL($modx->documentIdentifier) . '">clicking here</a>.</p>',$finalOutput);	

	
return $finalOutput;
?>